
/*
 * ServerMain.java
 * 服务器端的入口点。执行本文件以启动服务器。
 */
import java.net.*;
import java.io.*;
import java.util.concurrent.*;

public class ServerMain {
    static final ConcurrentHashMap<String, Socket> soc_by_name = new ConcurrentHashMap<String, Socket>();
    
    public static void main(String[] args)
    {
        Global.print_copyright("服务器端");
        try (ServerSocket svr = new ServerSocket(Global.SERVER_PORT)) {
            while (true) {
                try {
                    Socket conn = svr.accept();
                    new Thread(new Worker(conn)).start();
                    
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }        
    }
}